﻿using AbpEntityFrameworkcore.DbContext;
using AbpToDomain.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpApplication.Expand
{
    public class QueryDynamic_View_Log
    {

        private readonly MyDbContext context;
        public QueryDynamic_View_Log(MyDbContext context)
        {
            this.context = context;
        }
        public List<View_Log> QueryDynameic(string? Type, string? User,string? Note,string?OrderNo)
        {
            IQueryable<View_Log> view_Logs = context.View_Logs.OrderByDescending(x=>x.DateTime);
            if (!string.IsNullOrEmpty(Type))
            {
                view_Logs = view_Logs.Where(b => b.Type.Contains(Type));
            }
            if (!string.IsNullOrEmpty(User))
            {
                view_Logs = view_Logs.Where(b => b.User.Contains(User));
            }
            if (!string.IsNullOrEmpty(Note))
            {
                view_Logs = view_Logs.Where(b => b.Note.Contains(Note));
            }
            if (!string.IsNullOrEmpty(OrderNo))
            {
                view_Logs = view_Logs.Where(b => b.OrderNo.Contains(OrderNo));
            }
            return view_Logs.ToList();
        }
    }
}
